########## PXE Server for x64 Network Boot ##########

- This server acts as ProxyDHCP, TFTP and HTTP server.
- Supports both UEFI and Legacy network boot.

Secure Boot must be disabled or set to Audit mode in the BIOS/UEFI settings.
Otherwise, the client will fail to run the EFI boot binary.
You can re-enable Secure Boot once PXE boot is no longer required.

########## Basic Setup ##########

-Edit "appsettings.json" (in WPXE-Server base folder):
Update the "ServerSettings" section to set your server’s IPv4 address ("ServerIP").
You can also change the "HttpPort" if the default "80" conflicts with another service (e.g., an existing web server)

Example:
    "ServerIP": "192.168.1.10",
    "HttpPort": 80,

-Why manually set the IP?
Some machines may have multiple network interfaces.
By manually specifying the IP, you ensure the PXE server listens on the correct interface.

-Why an HTTP port?
iPXE uses HTTP to serve the boot files instead of TFTP, providing much faster and more reliable transfers.

##### Adding Boot images #####

1. Inside the WPXE-Server folder, go to:  
   "wwwroot\images\"

2. Create a new folder for your image with the desired name
   Example: "wwwroot\images\Windows 11 Pro"

3. Extract the **full contents** of your ISO directly into that folder

***You can add as many folders as you want***

Example: "wwwroot\images\Windows 11 Pro"
         "wwwroot\images\Windows 11 Home"
         "wwwroot\images\Windows 10 Pro"
         "wwwroot\images\WinPE"
         "wwwroot\images\GParted 1.7.0-12"

##### Boot settings #####

In "appsettings.json" (in WPXE-Server base folder), you have:

  "BootSettings": {
    "AutoIpxeConfig": true,
    "DefaultFolder": "",
    "BootMenuEnable": true
  },

Option 1 – Show boot menu
→ Set "BootMenuEnable": true
→ All folders inside "wwwroot\images\" will appear automatically
→ "DefaultFolder" is ignored

Option 2 – Direct boot (no menu, boots one image immediately)
→ Set "BootMenuEnable": false
→ Set "DefaultFolder" to the exact name of the folder you want to boot 
  Example: "DefaultFolder": "Windows 11 Pro",

***Note***
- The "DefaultFolder" field is required only when multiple folders exist.
- If there is only one folder inside "wwwroot\images\" , it will be selected automatically - you can leave "DefaultFolder" empty ("DefaultFolder": "",)
- If multiple folders exist and "DefaultFolder" is left empty ("DefaultFolder": "") - the first folder found will be selected by default.
 
Example for direct boot:
  "BootSettings": {
    "AutoIpxeConfig": true,
    "DefaultFolder": "Windows 11 Pro",
    "BootMenuEnable": false
  },

##### Important – Network sharing #####

You must create a network share for the "wwwroot\images" folder.
This only needs to be done once.

***Note***
The network share is required only for Windows installation images, it is not required for WinPE boot or Linux installation.
If you never plan to use Windows installation images, you can skip this step.

How to create the network share:

1. Open File Explorer  
2. Go to your WPXE-Server folder, then go inside the "wwwroot" folder 
3. Right-click the folder "images" → Click "Properties"
4. Go to the "Sharing" tab  
5. Click "Advanced Sharing…" 
6. Tick "Share this folder"
7. Click "Permissions"
8. Click "Add..." to add a user (only "Read" permission is required)
   ***Recommended: Create a dedicated local user such as "wpxeuser" with a simple password***
9. Click OK → OK → Close

##### Optional #####

When booting a Windows installation image (e.g., Windows 11 Pro),
you will be prompted for a username and password for the network share before the Windows Setup starts.

You can avoid interactive credential prompts by setting your username and password in environment variables.

Environment Variables:
WPXE_USERNAME
WPXE_PASSWORD

If you set the WPXE_USERNAME environment variable but WPXE_PASSWORD is empty or does not exist, it will prompt you for the password only.

***Security Recommendation***
It is recommended to create a dedicated local user with "Read" permission that has access only to the "wwwroot\images" folder share.
For example, "wpxeuser" with a simple password used solely for this purpose.
Avoid using an administrator account or storing highly sensitive passwords.

####################

You are now ready to start "WPXE-Server.exe".

The "appsettings.json" configuration is loaded at startup, preparing the "autoexec.ipxe" and "autoexec-legacy.ipxe" file automatically in the ".\wwwroot\" folder.

***Note:***
For advanced configuration and automation, refer to the sections below for details on the additional settings in "appsettings.json"
and information about "autoexec.ipxe" and "autoexec-legacy.ipxe".

#####################################################

##### Extra Files for WinPE images #####

***Note***
This feature applies only to WinPE images, not Windows installation images (e.g., Windows 11 Pro).

You can inject files into your WinPE images.

1. Inside your WinPE folder, create a subfolder exactly named: "extrafiles"  
   Example: "wwwroot\images\WinPE\extrafiles"

2. Place any files you want inside that folder.  
   Example:
   - "wwwroot\images\WinPE\extrafiles\startnet.cmd"
   - "wwwroot\images\WinPE\extrafiles\CustomScript.ps1" 
   - "wwwroot\images\WinPE\extrafiles\other.file" 

At server startup, "autoexec.ipxe/autoexec-legacy.ipxe" will be generated with these additional files included.

These additional files will be available in the "X:\Windows\System32\" folder when WinPE is booted.

This is useful for automating Windows installation or other tasks from a WinPE boot.

WinPE automatically executes "startnet.com" on startup.
By injecting a custom "startnet.com", this will override the default WinPE startup script.

#####################################################

##### Extra Information : ServerSettings #####

In "appsettings.json" (in WPXE-Server base folder) under "ServerSettings" section, you have:

	"AddNullTerminatorToBootfile": true,
	"UseLightEFIBoot": "true"

### AddNullTerminatorToBootfile ###

***Note:***
This setting can be modified dynamically and takes effect immediately while the server is running.

Controls whether the PXE boot filename sent by the server includes a null terminator at the end.

- Set to true (default):  
  The boot filename string is terminated with a null character.  
  This is required for strict compliance with some PXE clients, since certain firmware expects the boot filename to end with a null character.

- Set to false:  
  The boot filename string is sent without a null terminator.  
  Unlikely to be needed, but available if certain clients have issues.

### UseLightEFIBoot ###

***Note:***
This setting can be modified dynamically and takes effect immediately while the server is running.

Specifies which UEFI bootloader binary to use during PXE boot.

- Set to true (default):
  Use "snponly.efi", which relies on the UEFI firmware’s built‑in Simple Network Protocol (SNP) driver to communicate with the NIC.  
  - Smaller footprint.
  - Minimal code, faster load, lower memory usage.
  - Dependent on firmware SNP quality.

- Set to false:
  Use "ipxe.efi", which includes its own NIC drivers, independent of firmware.  
  - Bypasses buggy firmware SNP implementations.
  - Supports advanced features not always available through firmware SNP (iSCSI boot, FCoE, AoE, HTTPS, crypto/authentication).
  - Larger binary, slightly slower.

#####################################################

##### Extra Information : BootSettings #####

In "appsettings.json" (in WPXE-Server base folder) under "BootSettings" section, you have:

    "AutoIpxeConfig": true,
    "DefaultFolder": "",
    "BootMenuEnable": false

### AutoIpxeConfig ###

- Set to true (default): 
  The server will automatically generate "autoexec.ipxe" and "autoexec-legacy.ipxe".

- Set to false:
  Disable automatic generation of "autoexec.ipxe/autoexec-legacy.ipxe". 

If you are familiar with iPXE, you can create/edit your own custom "autoexec.ipxe".

***Note:***  
- Both "autoexec.ipxe" and "autoexec-legacy.ipxe" must be placed in the "wwwroot" folder.
- "autoexec.ipxe" is used for UEFI boot.
- "autoexec-legacy.ipxe" is required only for legacy boot.

If your environment supports UEFI boot exclusively, you can omit "autoexec-legacy.ipxe".
   
#####################################################

##### Extra Information : PathOverrides #####

In "appsettings.json" (in WPXE-Server base folder) under "PathOverrides" section, you have:

    "WebRootPath": "",
    "NetworkSharePath": ""

By default, the WPXE-Server serves all files from the built-in "wwwroot" folder next to the executable.

Some users may want to store these files elsewhere — for example on another drive, a mapped network drive, a NAS, or a remote server share.

You can achieve this by setting a new path in "WebRootPath".

Exemples:

-mapped driver or other local drive:
	"WebRootPath": "X:/wpxe-files"

-NAS or remote server:
	"WebRootPath": "//192.168.1.200/wpxe"

When using a custom "WebRootPath", you must manually copy these 2 required folders from the original "wwwroot" (next to WPXE-Server.exe) to your new location:
- images
- iPXE  

WPXE now will ignore the local "wwwroot" folder entirely and serve everything from the new location.

If you plan on using Windows installation images (e.g., Windows 11 Pro),
you must also set the "NetworkSharePath".

Exemples:

-using remote server or NAS:
	"PathOverrides": {
  	"WebRootPath": "//192.168.1.200/wpxe",                  
  	"NetworkSharePath": "//192.168.1.100/wpxe/images"
	},

-using mapped drive:
	"PathOverrides": {
  	"WebRootPath": "X:/wpxe",                  
  	"NetworkSharePath": "//192.168.1.100/wpxe/images"
	},

-using a local drive on the same computer:
	"PathOverrides": {
  	"WebRootPath": "D:/wpxe",                  
  	"NetworkSharePath": "//WPXE server IP/images"
	},

***Note*** If you use a local drive on the same computer, dont forget to configure a Network Share on the "images" folder in the new location.

This is required for WPXE to start a Windows installation Setup.

#####################################################